package com.manor.main.adapter;

import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.manor.common.utils.StringUtil;
import com.manor.main.R;
import com.manor.main.bean.UserFlowBean;
import com.manor.main.custom.flow.FlowLayout;
import com.manor.main.custom.flow.TagAdapter;

import java.util.List;

/**
 * @version 1.0
  
 * @date 2020/6/18  13:57
 */
public class MBasicAdapter extends TagAdapter<UserFlowBean> {
    private List<UserFlowBean> mList;

    public MBasicAdapter(List<UserFlowBean> datas) {
        super(datas);
        this.mList = datas;
    }

    @Override
    public View getView(FlowLayout parent, int position, UserFlowBean bean) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_tag_x, parent, false);
        TextView textView = view.findViewById(R.id.tv_text);
        textView.setText(" " + mList.get(position).getTitle());
        if (StringUtil.isNotEmpty(bean.getIsSex())) {
            Drawable drawable;
            if (bean.getIsSex().equals("1")) {
                drawable = parent.getContext().getResources().getDrawable(R.mipmap.gender_nan);
            } else {
                drawable = parent.getContext().getResources().getDrawable(R.mipmap.gender_nv);
            }
            drawable.setBounds(0, 0, drawable.getMinimumWidth(),
                    drawable.getMinimumHeight());
            textView.setCompoundDrawables(drawable, null, null, null);
        }
        //CustomizedUtil.instance.setSolid(textView,parent.getContext());
        return view;
    }


}

